import QtQuick
import QtQuick.Controls

Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")

    SwipeView {
        id: swipeView
        anchors.fill: parent
        currentIndex: pageIndicator.currentIndex

        Repeater {
            model: 5
            Page {
                Label {
                    text: "Page " + (index + 1)
                    anchors.centerIn: parent
                }
            }
        }
    }

    PageIndicator {
        id: pageIndicator
        interactive: true  // 启用点击跳转
        anchors {
            bottom: parent.bottom
            horizontalCenter: parent.horizontalCenter
            bottomMargin: 20
        }
        count: swipeView.count
        currentIndex: swipeView.currentIndex
        delegate: Rectangle {
            implicitWidth: 16
            implicitHeight: 16
            radius: width/2
            color: index === pageIndicator.currentIndex ? "#21be2b" : "#e0e0e0"

            Behavior on color {
                ColorAnimation { duration: 200 }
            }
        }
    }
}
